package com.ocm.burnningstar.View;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ocm.burnningstar.Model.SportUser;
import com.ocm.burnningstar.R;

import de.hdodenhof.circleimageview.CircleImageView;


/**
 * Created by ocm on 2018-01-30.
 */

public class CourseView extends LinearLayout {
    CircleImageView header;
    TextView name;
    TextView strength;
    TextView heartRate;
    TextView calorie;
    LinearLayout courseBack;
    View view;
    public CourseView(Context context, AttributeSet attrs) {
        super(context, attrs);
        view = LayoutInflater.from(context).inflate(R.layout.course, this, true);
//        int screenWidth = (int)(ScreenUtils.getScreenWidth()*0.92);
//        int screenHeight = (int)(ScreenUtils.getScreenHeight()*1.2);
//        int viewWidth = screenWidth/5;
//        int viewHeight = (int)(screenHeight*0.22);
//        AbsListView.LayoutParams params = new AbsListView.LayoutParams(viewWidth,viewHeight);
//        view.setLayoutParams(params);

        header = (CircleImageView)view.findViewById(R.id.header);
        name = (TextView) view.findViewById(R.id.name);
        strength = (TextView) view.findViewById(R.id.strength);
        heartRate = (TextView) view.findViewById(R.id.heartRate);
        calorie = (TextView) view.findViewById(R.id.calorie);
        courseBack =  (LinearLayout) view.findViewById(R.id.courseBack);


    }

    public void setData(SportUser user){
        header.setImageBitmap(user.getHeader());
        name.setText(user.getName());
        strength.setText(user.getStrength());
        calorie.setText(user.getCalorie());
        heartRate.setText(user.getHeartRate());
        courseBack.setBackgroundResource (user.getResource());
    }

}
